<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/24/024
 * Time: 20:37
 */

namespace app\api\model;

use think\facade\Session;

class CourseCate extends \think\Model
{
    /**
     * 获取单条
     * @param $id
     * @return array|null|\PDOStatement|string|\think\Model
     */
    public function _findOne($id){
        $data = $this->where([['id', '=', $id]])->find();

        return $data;
    }

    
    /**
    * 通过名称获取信息
    */
    public function _findByName($name){
        return $this->where([['title', '=', $name]])->find();
    }
    

   

    /**
     * 列表
     * @param array $condition
     * @param int $page_size
     * @param string $order_by
     * @return \think\Paginator
     */
    public function _list($where = '', $order_by="sort asc", $page_size = PAGE_SIZE_API){
        $obj = $this->order($order_by);
        $data = $this->where($where)
            ->field('*')
            ->order($order_by)
            ->paginate($page_size)
            ->toArray();
        return $data;
    }

    /**
    * 获取所有的类型
    */
    public function _getAll(){
        return  $this->order("sort")->limit(10)->select();
    }

}